package com.easepal7506a.project.ui.activity;

import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.widget.ImageView;

import com.easepal7506a.project.R;
import com.easepal7506a.project.observer.CloseDetailObserver;
import com.easepal7506a.project.observer.CloseScanAndAdjust;
import com.easepal7506a.project.ui.iview.IScanShoulderView7506;
import com.easepal7506a.project.ui.presenter.ScanShoulderPresenter7506;
import com.easepal7506a.project.utils.ActivityUtils;
import com.example.reslib.utils.DisplayUtil;
import com.ogawa.base.utils.CommonUtil;

/**
 * Created by FHB on 2018/3/27.
 */

public class ScanShoulderActivity7506 extends BaseActivity implements IScanShoulderView7506 ,CloseScanAndAdjust.onCloseActivity {
    private ImageView mIvScan;
    private AnimationDrawable mAnimation;
    private ImageView mIvBack;
    private ScanShoulderPresenter7506 mPresenter;

    @Override
    public void initTitleBar() {
        super.initTitleBar();
        showTitleBar(false);
    }

    @Override
    public void initView(int layoutId) {
        super.initView(layoutId);
        mPresenter = new ScanShoulderPresenter7506(this);
        mIvScan = findViewById(R.id.at_scan);
        mIvBack= findViewById(R.id.iv_back);
        mAnimation=(AnimationDrawable)mIvScan.getBackground();
        mAnimation.start();
        CommonUtil.setMargins(mIvBack,DisplayUtil.dip2px(this,20), CommonUtil.getStatusBarHeight(this),0,0);
        mIvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ScanShoulderActivity7506.this.finish();
                CloseDetailObserver.getInst().noticeonClose();
            }
        });
        CloseScanAndAdjust.getInst().registerObserver(this);
    }





    @Override
    protected void onDestroy() {
        super.onDestroy();
        mAnimation.stop();
        mIvScan.clearAnimation();
        mPresenter.onDestory();
        CloseScanAndAdjust.getInst().removeObserver(this);
    }





    @Override
    public int setLayoutId() {
        return R.layout.activity_scan_shoulder_7506;
    }




    @Override
    public void onBackPressed() {
        this.finish();
        CloseDetailObserver.getInst().noticeonClose();
    }




    @Override
    public void startToAdjust() {
        ActivityUtils.startShouldersAdjustmentActivity(this);
        this.finish();
    }

    @Override
    public void closeActivity() {
        this.finish();

    }

    @Override
    public void onClose() {
        this.finish();
    }
}
